package com.yzh.zhipu.session;

import com.yzh.zhipu.model.ChatRequest;
import com.yzh.zhipu.model.ChatResponse;
import com.yzh.zhipu.model.ImageRequest;
import com.yzh.zhipu.model.ImageResponse;
import okhttp3.sse.EventSource;
import okhttp3.sse.EventSourceListener;

import java.io.IOException;
import java.util.concurrent.CompletableFuture;

public interface ChatGlmSession {
    /**
     * 使用OkHttp3 SSE调用方式
     * @param request
     * @param eventSourceListener 事件流回调接口
     * @return
     */
    EventSource completions(ChatRequest request, EventSourceListener eventSourceListener);

    /**
     * 使用OkHttp3 同步调用
     * @param chatRequest
     * @return
     */
    ChatResponse completionsSync(ChatRequest chatRequest) throws IOException;
    
    /**
     * 使用CompletableFuture同步响应结果
     *
     * @param request
     * @return
     */
    CompletableFuture completions(ChatRequest request);

    /**
     * 生成图片
     *
     * @param request
     * @return
     */
    ImageResponse genImage(ImageRequest request) throws IOException;

}
